.TH CTAGS 1 "Version 3.5.1" "Darren Hiebert"


.SH NAME
ctags \- Generate tag files for source code


.SH SYNOPSIS
.TP 6
\fBctags\fP [\fBoptions\fP] [\fIfile(s)\fP]
.TP 6
\fBetags\fP [\fBoptions\fP] [\fIfile(s)\fP]


.SH DESCRIPTION
The \fBctags\fP and \fBetags\fP programs (hereinafter collectively referred to
as \fBctags\fP, except where distinguished) generate an index (or "tag") file
for C, C++, Eiffel, Fortran, and Java language objects found in \fIfile(s)\fP.
This tag file allows these items to be quickly and easily located by a text
editor or other utility. A "tag" signifies a language object for which an
index entry is available (or, alternatively, the index entry created for that
object).

.PP
Alternatively, \fBctags\fP can generate a cross reference file which lists, in
human readable form, information about the various source objects found in a
set of language files.

.PP
Tag index files are supported by numerous editors, which allow the user to
locate the object associated with a name appearing in a source file and jump
to the file and line which defines the name. Those known about at the time of
release are:

.PP
.RS 4
\fBvi\fP(1) and its many derivatives
.br
\fBemacs\fP
.br
\fBCRiSP\fP
.br
\fBFTE\fP (Folding Text Editor)
.br
\fBLemmy\fP
.br
\fBNEdit\fP
.br
\fBTSE\fP (The SemWare Editor)
.br
\fBZeus\fP
.RE

.PP
\fBCtags\fP is capable of generating tags for all of the following language
constructs:

.PP
.RS 4
C/C++:
.RE
.RS 8
macros (names defined/undefined by #define/#undef)
.br
enumerators (enumerated values)
.br
function definitions, prototypes, and declarations
.br
class, enum, struct, and union names
.br
namespaces
.br
typedefs
.br
variables (definitions and declarations)
.br
class, struct, and union members
.RE

.RS 4
Eiffel:
.RE
.RS 8
classes
.br
features
.br
local entities
.RE

.RS 4
Fortran:
.RE
.RS 8
block data
.br
common blocks
.br
entry points
.br
functions
.br
interfaces
.br
labels
.br
modules
.br
namelists
.br
programs
.br
subroutines
.br
derived types
.RE

.RS 4
Java:
.RE
.RS 8
classes
.br
fields
.br
interfaces
.br
methods
.br
packages
.RE


.SH "SOURCE FILES"

The language of each source file is automatically selected based upon its file
extension (unless the \fB--lang\fP option is specified). File extensions are
mapped to source file languages according to the following default mapping
(unless the \fB--langmap\fP option is specified):

.PP
.PD 0
.RS 4
.TP 9
.B C
*.c
.TP 9
.B C++
*.C *.c++ *.cc *.cpp *.cxx *.h *.H *.hh *.hpp *.hxx *.h++
.TP 9
.B Eiffel
*.e
.TP 9
.B Fortran
*.f *.for *.ftn *.f77 *.f90 *.f95 *.F *.FOR *.FTN *.F77 *.F90 *.F95
.TP 9
.B Java
*.java
.PD 1
.RE

.PP
By default, all other files extensions are ignored. This permits running
\fBctags\fP on all files in either a single directory (e.g. "ctags *"), or all
files in an entire source directory tree (e.g. "ctags -R"), since only those
files whose extensions are known to \fBctags\fP will be scanned.

.PP
The reason that .h extensions are mapped to C++ files rather than C files
is because no information is lost and because it is common to use .h
extensions in C++, where information would be lost if .h files were parsed
with C rules.


.SH OPTIONS

Despite the wealth of available options, defaults are set so that \fBctags\fP
is most commonly executed without any options (e.g. "ctags *"), which will
create a tag file in the current directory for all known source files. The
options described below are provided merely to allow custom tailoring to meet
special needs.

.PP
Note that spaces separating the single-letter options from their parameters
are optional.

.PP
Note also that the boolean parameters to the long form options (those
beginning with "--" and that take a "=\fIyes\fP|\fIno\fP" parameter) may
be omitted, in which case "\fB=\fP\fIyes\fP" is implied. (e.g. \fB--sort\fP
is equivalent to \fB--sort\fP=\fIyes\fP). Note further that "=\fI1\fP" and
"=\fIon\fP" are considered synonyms for "=\fIyes\fP", and that "=\fI0\fP"
and "=\fIoff\fP" are considered synonyms for "=\fIno\fP".

Some options are either ignored, or only useful, when used together with
\fBetags\fP or, equivalently, when \fBctags\fP is run with the \fI-e\fP
option. These options will be noted.

Most options may appear anywhere on the command line, affecting only those
files which follow the option. A few options, however, must appear before the
first file name and will be noted as such.

.TP 5
.B \-a
Equivalent to \fB--append\fP.

.TP 5
.B \-B
Use backward searching patterns (e.g. ?regexp?). [Ignored with \fB-e\fP]

.TP 5
.B \-e
Output a tag file for use with Emacs. If this program is executed by the name
\fBetags\fP, this option is enabled by default. This option must appear before
the first file name.

.TP 5
.BI \-f " tagfile"
Use the name specified by \fItagfile\fP for the tag file (default is "tags",
or "TAGS" when using the \fB-e\fP option). If \fItagfile\fP is specified as
"-", then the tag file is written to standard output instead. \fBCtags\fP
will stubbornly refuse to take orders if \fItagfile\fP exists and its first
line contains something other than a valid tags line. This will save your neck
if you mistakenly type "ctags -f *.c", which would otherwise overwrite your
first C file with the tags generated by the rest! This option must appear
before the first file name. If this option is specified more than once, only
the last will apply.

.TP 5
.B \-F
Use forward searching patterns (e.g. /regexp/) (default).
[Ignored with \fB-e\fP]

.TP 5
.BI \-h  " list"
Specifies a list of file extensions, separated by periods, which are to be
interpreted as include, or header, files. This option affects how the scoping
of tag types is interpreted (i.e. whether or not they are considered as
globally visible or visible only within the file in which they are defined).
Any tag type which is located in a non-include file and cannot be seen (e.g.
linked to) from another file is considered to have file-limited (e.g. static)
scope. No tag type appearing in an include file will be considered to have
file-limited scope. If the first character in the list is a plus sign, then
the extensions in the list will be appended to the current list; otherwise,
the list will replace the current list. See also the \fB--file-scope\fP
option. The default list is ".h.H.hh.hpp.hxx.h++.inc.def".
To restore the default list, specify \fB-h\fP \fIdefault\fP.

.TP 5
.BI \-i " types"
This option is similar to the \fB--c-types\fP option and is retained for
compatibility with earlier versions. If \fItypes\fP begins with the '='
character, it is equivalent to \fB--c-types\fP=\fItypes\fP. Otherwise, it is
equivalent to \fB--c-types\fP=\fI+types\fP. In addition, for backward
compatibility, the following two additional modifiers are accepted:

.PP
.PD 0
.RS 8
.TP 4
.I F
An alternative for the \fB--file-tags\fP option.
.TP 4
.I S
An alternative for the \fB--file-scope\fP option.
.RE
.PD 1

.TP 5
.BI \-I " tokenlist"
Specifies a list of tokens which are to be specially handled while parsing C
and C++ source files. This option is specifically provided to handle special
cases arising through the use of preprocessor macros. When the tokens listed
are simple tokens, these tokens will be ignored during parsing of the source
files. If a token is suffixed with a '+' character, \fBctags\fP will also
ignore any parenthesis-enclosed argument list which may immediately follow the
token in the source files. If two tokens are separated with the '=' character,
the first token is replaced by the second token for parsing purposes. The list
of tokens may be supplied directly on the command line or read in from a
separate file. If the first character of \fItokenlist\fP is either a '.' or a
pathname separator ('/' or '\\'), the parameter \fItokenlist\fP will be
interpreted as a filename from which to read a list of white-space delimited
tokens (use "./filename" to specify a file found in the current directory).
Otherwise, \fItokenlist\fP is a list of tokens (or token pairs) to be
specially handled, each delimited by a either a comma or by white space (in
which case the list should be quoted to keep the entire list as one command
line argument). Multiple \fB-I\fP options may be supplied. To clear the list
of ignore tokens, supply a single dash ("-") for \fItokenlist\fP.

.RS 5
.PP
This feature is useful when preprocessor macros are used in such a way that
they cause syntactic confusion due to their presence. Indeed, this is the best
way of working around a number of problems caused by the presence of
syntax-busting macros in source files (see \fBBUGS\fP, below). Some examples
will illustrate this point.
.RE

.PP
.RS 8
int foo ARGDECL4(void *, ptr, long int, nbytes)
.RE

.PP
.RS 5
In the above example, the macro "ARGDECL4" would be mistakenly interpreted to
be the name of the function instead of the correct name of "foo". Specifying
\fB-I\fP \fIARGDECL4\fP results in the correct behavior.
.RE

.PP
.RS 8
/* creates an RCS version string in module */
.br
MODULE_VERSION("$Revision: 8.25 $")
.RE

.PP
.RS 5
In the above example the macro invocation looks too much like a function
definition because it is not followed by a semicolon (indeed, it could even be
followed by a global variable definition that would look much like a K&R style
function parameter declaration). In fact, this seeming function definition
could possibly even cause the rest of the file to be skipped over while trying
to complete the definition. Specifying \fB-I\fP \fIMODULE_VERSION+\fP would
avoid such a problem.
.RE

.PP
.RS 8
CLASS Example {
.br
.RS 4
// your content here
.RE
.br
};
.RE

.RS 5
.PP
The example above uses "CLASS" as a preprocessor macro which expands to
something different for each platform. For instance CLASS may be defined as
"class __declspec(ddlexport)" on Win32 platforms and simply "class" on UNIX.
Normally, the absence of the C++ keyword "class" would cause the source file
to be incorrectly parsed. Correct behavior can be restored by specifying
\fB-I\fP \fICLASS=class\fP.
.RE

.TP 5
.BI \-L " file"
Read from \fIfile\fP a list of file names for which tags should be generated.
If \fIfile\fP is specified as "-", then file names are read from standard
input. File names read using this option are processed following file names
appearing on the command line. Options all also accepted in this input. If
this option is specified more than once, only the last will apply. \fBNote:\fP
\fIfile\fP is read in line-oriented mode, where a new line is the only
delimiter and spaces are considered significant, in order that file names
containing spaces may be supplied; this can affect how options are parsed if
included in the input.

.TP 5
.B \-n
Equivalent to \fB--excmd\fP=\fInumber\fP.

.TP 5
.B \-N
Equivalent to \fB--excmd\fP=\fIpattern\fP.

.TP 5
.BI \-o " tagfile"
Equivalent to \fB-f\fP \fItagfile\fP.

.TP 5
.BI \-p " path"
Use \fIpath\fP as the default directory for each supplied source file (whether
supplied on the command line or in a file specified with the \fB-L\fP option),
unless the source file is already specified as an absolute path. The supplied
\fIpath\fP is merely prepended to the each non-absolute source file name
(adding any necessary path separator) before attempting to open it.

.TP 5
.B \-R
Equivalent to \fB--recurse\fP.

.TP 5
.B \-u
Equivalent to \fB--sort\fP=\fIno\fP (i.e. "unsorted").

.TP 5
.B \-V
Equivalent to \fB--verbose\fP.

.TP 5
.B \-x
Print a tabular, human-readable cross reference (xref) file to standard output
instead of generating a tag file. The information contained in the output
includes: the tag name; the kind of tag; the line number, file name, and
source line (with extra white space condensed) of the file which defines the
tag. No tag file is written and all options affecting tag file output will be
ignored. Example applications for this feature are generating a listing of all
functions located in a source file (e.g. \fBctags -x --c-types\fP=\fIf\fP
\fIfile\fP), or generating a list of all externally visible global variables
located in a source file (e.g. \fBctags -x --c-types\fP=\fIv\fP
\fB--file-scope\fP=\fIno file\fP). This option must appear before the first
file name.

.TP 5
\fB--append\fP=\fIyes\fP|\fIno\fP
Indicates whether tags generated from the specified files should be appended
to those already present in the tag file or should replace them. This option
is off by default. This option must appear before the first file name.
[Ignored with \fB-e\fP]

.TP 5
\fB--c-types\fP=\fItypes\fP
Specifies a list of C/C++ language tag types to include in the output file.
The parameter \fItypes\fP is a group of one-letter flags designating types of
tags (listed below) to either include or exclude from the output. Each letter
or group of letters may be preceded by either '+' to add it to the default
set, or '-' to exclude it. In the absence of any preceding '+' or '-' sign,
only those types explicitly listed in \fItypes\fP will be included in the
output (i.e. overriding the default). For example, to exclude macros but
include prototypes, use \fB--c-types\fP=\fI-d+p\fP; to include only tags for
functions, use \fB--c-types\fP=\fIf\fP. Tags for the following language
constructs are supported (types are enabled by default except as noted):

.PP
.RS 8
.PD 0
.TP 4
.I c
classes
.TP 4
.I d
macro definitions (and #undef names)
.TP 4
.I e
enumerators
.TP 4
.I f
function definitions
.TP 4
.I g
enumeration names
.TP 4
.I m
class, struct, or union members
.TP 4
.I n
namespaces
.TP 4
.I p
function prototypes and declarations [off]
.TP 4
.I s
structure names
.TP 4
.I t
typedefs
.TP 4
.I u
union names
.TP 4
.I v
variable definitions
.TP 4
.I x
extern and forward variable declarations [off]
.RE
.PD 1

.PP
.RS 5
In addition to the above flags, the following one-letter modifiers are
accepted:
.RE

.PP
.RS 8
.PD 0
.TP 4
.I A
Record the access of each member into the tag file. This information is
recorded using an extension flag labeled "access".
.PP
.TP 4
.I C
Include an extra, class-qualified tag entry for each class member in the form
"class::member". This allows locating class-qualified tags (e.g. ":tag
class::member" in \fBvi\fP(1)). This is disabled by default because this could
potentially more than double the size of the tag file.
.PD 1
.RE

.PP
.RS 5
.RE

.TP 5
\fB--eiffel-types\fP=\fItypes\fP
Specifies a list of Eiffel language tag types to be included in the output.
See \fB--c-types\fP for the definition of the format of \fItypes\fP. Tags for
the following Eiffel language constructs are supported (types are enabled by
default except as noted):

.PP
.RS 8
.PD 0
.TP 4
.I c
classes
.TP 4
.I f
features
.TP 4
.I l
local entities [off]
.RE
.PD 1
.RE

.PP
.RS 5
In addition to the above flags, the following one-letter modifiers are
accepted:
.RE

.PP
.RS 8
.PD 0
.TP 4
.I C
Include an extra, class-qualified tag entry for each class member in the form
"class.member". This allows locating class-qualified tags (e.g. ":tag
class.member" in \fBvi\fP(1)). This is disabled by default because this could
potentially more than double the size of the tag file.
.PD 1
.RE

.TP 5
\fB--etags-include\fP=\fIfile\fP
Include a reference to \fIfile\fP in the tag file. This option may be
specified as many times as desired. This supports Emacs' capability to use a
tag file which "includes" other tag files. [Used only with \fB-e\fP]

.TP 5
\fB--excmd\fP=\fItype\fP
Determines the type of EX command used to locate tags in the source file.
[Ignored with \fB-e\fP]

.PP
.RS 5
The valid values for \fItype\fP (either the entire word or the first letter is
accepted) are:
.TP 9
.I number
Use only line numbers in the tag file for locating tags. This has four
advantages:
.PD 0
.RS 9
.TP 4
1.
Significantly reduces the size of the resulting tag file.
.TP 4
2.
Eliminates failures to find tags because the line defining the tag has
changed, causing the pattern match to fail (note that some editors, such as
\fBvim\fP, are able to recover in many such instances).
.TP 4
3.
Eliminates finding identical matching, but incorrect, source lines (see
\fBBUGS\fP, below).
.TP 4
4.
Retains separate entries in the tag file for lines which are identical in
content. In \fIpattern\fP mode, duplicate entries are dropped because the
search patterns they generate are identical, making the duplicate entries
useless.

.PP
However, this option has one significant drawback: changes to the source files
can cause the line numbers recorded in the tag file to no longer correspond
to the lines in the source file, causing jumps to some tags to miss the target
definition by one or more lines. Basically, this option is best used when the
source code to which it is applied is not subject to change. Selecting this
option type causes the following options to be ignored: \fB-BF\fP.
.RE
.PD 1

.TP 9
.I pattern
Use only search patterns for all tags, rather than the line numbers usually
used for macro definitions. This has the advantage of not referencing obsolete
line numbers when lines have been added or removed since the tag file was
generated.

.TP 9
.I mixed
In this mode, patterns are generally used with a few exceptions. For C, line
numbers are used for macro definition tags. This was the default format
generated by the original \fBctags\fP and is, therefore, retained as the
default for this option. For Fortran, line numbers are used for common blocks
because their corresponding source lines are generally identical, making
pattern searches useless for finding all matches.
.RE

.TP 5
\fB--file-scope\fP=\fIyes\fP|\fIno\fP
Indicates whether tags scoped only for a single file (i.e. tags which cannot
be seen outside of the file in which they are defined, such as "static" tags)
should be included in the output. See also the \fB-h\fP option. This option is
enabled by default.

.TP 5
\fB--file-tags\fP=\fIyes\fP|\fIno\fP
Indicates whether tags should be generated for source file names. This option
is disabled by default.

.TP 5
\fB--filter\fP=\fIyes\fP|\fIno\fP
Causes \fBctags\fP to behave as a filter, reading source file names from
standard input and printing their tags to standard output on a file-by-file
basis. If \fB--sorted\fP is enabled, tags are sorted only within the source
file in which they are defined. File names are read from standard output in
line-oriented input mode (see note for \fB-L\fP option) and only after file
names listed on the command line or from any file supplied using the \fB-L\fP
option. When this option is enabled, the options \fB-f\fP, \fB-o\fP,
and \fB--totals\fP are ignored. This option is quite estoteric and is disabled
by default. This option must appear before the first file name.

.TP 5
\fB--filter-terminator\fP=\fIstring\fP
Specifies a string to print to standard output following the tags for each
file name parsed when the \fB--filter\fP option is enabled. This may permit an
application reading the output of ctags to determine when the output for each
file is finished. Note that if the file name read is a directory and
\fB--recurse\fP is enabled, this string will be printed only one once at the
end of all tags found for by descending the directory. This string will always
be separated from the last tag line for the file by its terminating newline.
This option is quite esoteric and is empty by default. This option must appear
before the first file name.

.TP 5
\fB--format\fP=\fIlevel\fP
Change the format of the output tag file. Currently the only valid values for
\fIlevel\fP are \fI1\fP or \fI2\fP. Level 1 specifies the original tag file
format and level 2 specifies a new extended format containing extension flags
(but in a manner which retains backward compatibility with original
\fBvi\fP(1) implementations). The default level is 2. This option must appear
before the first file name. [Ignored with \fB-e\fP]

.TP 5
\fB--fortran-types\fP=\fItypes\fP
Specifies a list of Fortran language tag types to be included in the output.
See \fB--c-types\fP for the definition of the format of \fItypes\fP. Tags for
the following Fortran language constructs are supported (types are enabled
by default except as noted):

.PP
.RS 8
.PD 0
.TP 4
.I b
block data
.TP 4
.I c
common blocks
.TP 4
.I e
entry points
.TP 4
.I f
functions
.TP 4
.I i
interfaces
.TP 4
.I l
labels [off]
.TP 4
.I m
modules
.TP 4
.I n
namelists
.TP 4
.I p
programs
.TP 4
.I s
subroutines
.TP 4
.I t
derived types
.RE
.PD 1
.RE

.TP 5
.B \--help
Prints to standard output a detailed usage description.

.TP 5
\fB--if0\fP=\fIyes\fP|\fIno\fP
Indicates a preference as to whether code within an "#if 0" branch of a
preprocessor conditional should be examined for non-macro tags (macro tags are
always included). Because the intent of this construct is to disable code, the
default value of this options is \fIno\fP. Note that this indicates a
preference only and does not guarantee skipping code within an "#if 0" branch,
since the fall-back algorithm used to generate tags when preprocessor
conditionals are too complex follows all branches of a conditional. This
option is disabled by default.

.TP 5
\fB--java-types\fP=\fItypes\fP
Specifies a list of Java language tag types to be included in the output.
See \fB--c-types\fP for the definition of the format of \fItypes\fP. Tags for
the following Java language constructs are supported (all are enabled by
default):

.PP
.RS 8
.PD 0
.TP 4
.I c
classes
.TP 4
.I f
fields
.TP 4
.I i
interfaces
.TP 4
.I m
methods
.TP 4
.I p
packages
.RE
.PD 1
.RE

.PP
.RS 5
In addition to the above flags, the following one-letter modifiers are
accepted:
.RE

.PP
.RS 8
.PD 0
.TP 4
.I A
Record the access of each field into the tag file. This information is
recorded using an extension flag labeled "access".
.TP 4
.I C
Include an extra, class-qualified tag entry for each class member in the form
"class.member". This allows locating class-qualified tags (e.g. ":tag
class.member" in \fBvi\fP(1)). This is disabled by default because this could
potentially more than double the size of the tag file.
.PD 1
.RE

.PP
.RS 5
.RE

.TP 5
\fB--kind-long\fP=\fIyes\fP|\fIno\fP
Specifies whether the identifier for the kind of the tag listed in extension
flags of the tag file is a verbose name or a single letter. See the
description of \fIkind\fP in \fBEXTENSION FLAGS\fP, below. When enabled, this
will increase the size of the output by an average of about 5 characters per
line or, roughly, 5%. This option must appear before the first file name.

.TP 5
\fB--lang\fP=\fIauto\fP|\fIc\fP|\fIc++\fP|\fIeiffel\fP|\fIfortran\fP|\fIjava\fP
By default, \fBctags\fP automatically selects the language of a source file
according to its file name extension, ignoring those files whose extensions
are unrecognized by \fBctags\fP. This option forces the specified language to
be used for every supplied file instead of automatically selecting the
language based upon its extension. The default is \fIauto\fP.

.TP 5
\fB--langmap\fP=\fImap(s)\fP
Changes the mapping between file extensions and source languages (see
\fBSOURCE FILES\fP, above). Each comma-separated \fImap\fP consists of the
source language name, a colon, and a list of extensions separated by periods.
If the first character in a map is a plus sign, then the extensions in that
map will be appended to the current map for that language; otherwise, the map
will replace the current map. For example, to specify that only files with
extensions of .c, .ec, and .xs are to be treated as C language files, use
"\fB--langmap\fP=\fIc:.c.ec.xs\fP". To also specify that files with extensions
of .j are to be treated as Java language files, use
"\fB--langmap\fP=\fIc:.c.ec.xs,java:+.j\fP". To clear the mapping for a
particular language (thus preventing generation of tags for that language),
specify an empty extension list (e.g. "\fB--langmap\fP=\fIFortran:\fP"). To
restore the default language mappings for all a particular language, supply
the keyword "default" for the mapping. To specify restore the default language
mappings for all languages, specify \fB--langmap\fP=\fIdefault\fP.

.TP 5
\fB--line-directives\fP=\fIyes\fP|\fIno\fP
Specifies whether "#line" directives should be recognized. These are present
in the output of preprocessors and contain the line number, and possibly the
file name, of the original source file(s) from which the preprocessor output
file was generated. When enabled, this option will cause \fBctags\fP to
generate tag entries marked with the file names and line numbers of their
locations original source file(s), instead of their actual locations in the
preprocessor output. The actual file names placed into the tag file will have
the same leading path components as the preprocessor output file, since it is
assumed that the original source files are located relative to the
preprocessor output file (unless, of course, the #line directive specifies an
absolute path). This option is off by default. \fBNote:\fP This option is
generally only useful when used together with the \fB--excmd\fP=\fInumber\fP
(\fB-n\fP) option. Also, you may have to use either the \fB--lang\fP or
\fB--langmap\fP option if the extension of the preprocessor output file is not
known to \fBctags\fP.

.TP 5
\fB--links\fP=\fIyes\fP|\fIno\fP
Indicates whether symbolic links (if suppported) should be followed. When
disabled, symbolic links are ignored. This option is on by default.

.TP 5
\fB--recurse\fP=\fIyes\fP|\fIno\fP
Recurse into directories encountered in the list of supplied files. If the
list of supplied files is empty and no file list is specified with the
\fB-L\fP option, then the current directory (i.e. ".") is assumed. On Unix,
directories named "SCCS" are skipped, because files in these directories are
not source code, even though they have the same names as the source code to
which they relate. Directories named "EIFGEN" are skipped, because these
contain Eiffel compiler-generated C files. Also on Unix, symbolic links are
followed. If you don't like these behaviors, either explicitly specify the
files or pipe the output of \fBfind\fP(1) into \fBctags -L-\fP instead.
\fBNote:\fP This option is not supported on all platforms at present.

.TP 5
\fB--sort\fP=\fIyes\fP|\fIno\fP
Indicates whether the tag file should be sorted on the tag name (default is
\fIyes\fP). Note that the original \fBvi\fP(1) requires sorted tags. This
option is on by default. This option must appear before the first file name.
[Ignored with \fB-e\fP]

.TP 5
\fB--totals\fP=\fIyes\fP|\fIno\fP
Prints statistics about the source files read and the tag file written during
the current invocation of \fBctags\fP. This option is off by default.
This option must appear before the first file name.

.TP 5
\fB--verbose\fP=\fIyes\fP|\fIno\fP
Enable verbose mode. This prints out information on option processing and a
brief message describing what action is being taken for each file considered
by \fBctags\fP. Normally, \fBctags\fP does not read command line arguments
until after options are read from the configuration files (see \fBFILES\fP,
below) and the \fBCTAGS\fP environment variable. However, if this option is
the first argument on the command line, it will take effect before any options
are read from these sources.

.TP 5
\fB--version\fP
Prints a version identifier for \fBctags\fP to standard output. This is
guaranteed to always contain the string "Exuberant Ctags".


.SH "OPERATIONAL DETAILS"
For every one of the qualified objects which are discovered in the source
files supplied to \fBctags\fP, a separate line is added to the tag file, each
looking like this in the most general case:

.PP
.RS 4
tag_name    file_name    ex_cmd;"    xflags
.RE

.PP
The fields and separators of these lines are specified as follows:

.PP
.PD 0
.RS 4
.TP 4
1.
tag name (a C language identifier)
.TP 4
2.
a single tab character
.TP 4
3.
the name of the file in which the object associated with the tag is located
.TP 4
4.
a single tab character
.TP 4
5.
an EX command to locate the tag within the file; generally a search pattern
(either /pattern/ or ?pattern?) or line number (see \fB--excmd\fP). Tag file
format 2 (see \fB--format\fP) extends this EX command under certain
circumstances to include a set of extension flags (see \fBEXTENSION FLAGS\fP,
below) embedded in an EX comment immediately appended to the EX command, which
leaves it backwards compatible with original \fBvi\fP(1) implementations.
.RE
.PD 1

.PP
A few special tags are written into the tag file for internal purposes. These
tags are composed in such a way that they always sort to the top of the file.
Therefore, the first two characters of these tags are used a magic number to
detect a tag file for purposes of determining whether a valid tag file is
being overwritten rather than a source file.

.PP
When this program is invoked by the name \fBetags\fP, or with the \fB-e\fP
option, the output file is in a different format that is used by \fBemacs\fP(1).

.PP
Note that the name of each source file will be recorded in the tag file
exactly as it appears on the command line. Therefore, if the path you
specified on the command line was relative to some directory, then it will
be recorded in that same manner in the tag file.

.PP
This version of \fBctags\fP imposes no formatting requirements. Other versions
of ctags tended to rely upon certain formatting assumptions in order to help
it resolve coding dilemmas caused by preprocessor conditionals.

.PP
In general, \fBctags\fP tries to be smart about conditional preprocessor
directives. If a preprocessor conditional is encountered within a statement
which defines a tag, \fBctags\fP follows only the first branch of that
conditional (except in the special case of "#if 0", in which case it follows
only the last branch). The reason for this is that failing to pursue only one
branch can result in ambiguous syntax, as in the following example:

.PP
.RS
#ifdef TWO_ALTERNATIVES
.br
struct {
.br
#else
.br
union {
.br
#endif
.RS 4
short a;
.br
long b;
.RE
}
.RE

.PP
Both branches cannot be followed, or braces become unbalanced and \fBctags\fP
would be unable to make sense of the syntax.

.PP
If the application of this heuristic fails to properly parse a file,
generally due to complicated and inconsistent pairing within the conditionals,
\fBctags\fP will retry the file using a different heuristic which does not
selectively follow conditional preprocessor branches, but instead falls back
to relying upon a closing brace ("}") in column 1 as indicating the end of a
block once any brace imbalance results from following a #if conditional branch.

.PP
\fBCtags\fP will also try to specially handle arguments lists enclosed in
double sets of parentheses in order to accept the following conditional
construct:

.PP
.RS
extern void foo __ARGS((int one, char two));
.RE

.PP
Any name immediately preceding the "((" will be automatically ignored and
the previous name will be used.

.PP
C++ operator definitions are specially handled. In order for consistency with
all types of operators (overloaded and conversion), the operator name in the
tag file will always be preceded by the string "operator " (i.e. even if the
actual operator definition was written as "operator<<").

.PP
After creating or appending to the tag file, it is sorted by the tag name,
removing identical tag lines.

.PP
Note that the path recorded for filenames in the tag file and utilized by
the editor to search for tags are identical to the paths specified for
\fIfile(s)\fP on the command line. This means the if you want the paths for
files to be relative to some directory, you must invoke \fBctags\fP with the
same pathnames for \fIfile(s)\fP (this can be overridden with \fB-p\fP).


.SH "EXTENSION FLAGS"

Extension flags are tab-separated key-value pairs appended to the end of the
EX command as a comment, as described above in \fBOPERATIONAL DETAILS\fP.
These key value pairs appear in the general form "\fIkey\fP:\fIvalue\fP".
The possible keys and the meaning of their values are as follows:

.TP 12
.I access
Indicates the visibility of this class member, where \fIvalue\fP is specific
to the language.

.TP 12
.I class
Indicates that this tag is a member of the class whose name is given by
\fIvalue\fP.

.TP 12
.I enum
Indicates that this tag is a member of the enumeration whose name is given by
\fIvalue\fP.

.TP 12
.I file
Indicates that the tag has a file-limited scope (i.e. is static to the file).
This key has no corresponding value.

.TP 12
.I kind
Indicates the type of the tag. Its value is either one of the corresponding
one-letter flags described under the various \fB--<lang>-types\fP options
above, or a full name, depending upon the value of the \fB--kind-long\fP
option. Alternatively, this key may be omitted, with only its value present
(i.e. a field without a ':' defaults to the \fIkind\fP key).

.TP 12
.I implementation
When present, this indicates a limited implementation (abstract vs. concrete)
of a routine or class, where \fIvalue\fP is specific to the language
("virtual" or "pure virtual" for C++; "abstract" for Java).

.TP 12
.I inherits
When present, \fIvalue\fP. is a comma-separated list of classes from which
this class is derived (i.e. inherits from).

.TP 12
.I interface
Indicates that this tag is a member of the interface whose name is given by
\fIvalue\fP.

.TP 12
.I namespace
Indicates that this tag is a member of the namespace whose name is given by
\fIvalue\fP.

.TP 12
.I struct
Indicates that this tag is a member of the structure whose name is given by
\fIvalue\fP.

.TP 12
.I union
Indicates that this tag is a member of the union whose name is given by
\fIvalue\fP.


.SH "ENVIRONMENT VARIABLES"

.TP 8
.B CTAGS
If this enviroment variable exists, it will be expected to contain a set of
default options which are read when \fBctags\fP starts, after the
configuration files listed in \fBFILES\fP, below, are read, but before any
command line options are read. Options appearing on the command line will
override options specified in this file. Only options will be read from this
file.

.TP 8
.B ETAGS
Similar to the \fBCTAGS\fP variable above, this variable, if found, will be
read when \fBetags\fP starts. If this variable is not found, \fBetags\fP will
try to use \fBCTAGS\fP instead.

.TP 8
.B TMPDIR
On Unix-like hosts where mkstemp() is available, the value of this variable
specifies the directory in which to place temporary files. This can be useful
if the size of a temporary file becomes too large to fit on the partition
holding the default temporary directory defined at compilation time.
\fBctags\fP creates temporary files only if either (1) an emacs-style tag file
is being generated, (2) the tag file is being sent to standard output, or (3)
the program was compiled to use an internal sort algorithm to sort the tag
files instead of the the sort utility of the operating system. If the sort
utility of the operating system is being used, it will generally observe this
variable also. Note that if \fBctags\fP is setuid, the value of TMPDIR will be
ignored.

.SH "HOW TO USE WITH VI"
Vi will, by default, expect a tag file by the name "tags" in the current
directory. Once the tag file is built, the following commands exercise the tag
indexing feature:
.TP 12
.B vi -t tag
Start vi and position the cursor at the file and line where "tag" is defined.
.TP 12
.B Control-]
Find the tag under the cursor.
.TP 12
.B :ta tag
Find a tag.
.TP 12
.B Control-T
Return to previous location before jump to tag (not widely implemented).


.SH "HOW TO USE WITH GNU EMACS"
Emacs will, by default, expect a tag file by the name "TAGS" in the current
directory. Once the tag file is built, the following commands exercise the
tag indexing feature:
.TP 12
.B "Meta-x visit-tags-table"
Visit a TAGS file.
.TP 12
.B "Meta-."
Find a definition for a tag.  The default tag is the identifier under the
cursor.  There is name completion in the minibuffer; typing \fB"foo TAB"\fP
completes the identifier starting with `foo' (`foobar', for example) or lists
the alternatives.
.TP 12
.B "Meta-,"
Find the next definition for the tag.  Exact matches are found first, followed
by fuzzier matches.

.PP
For more commands, see the \fITags\fP topic in the Emacs info tree.


.SH "BUGS (CAVEATS)"
\fBCtags\fP has as many options as \fBls\fP(1).

.PP
Because \fBctags\fP is neither a preprocessor nor a compiler, use of
preprocessor macros can fool \fBctags\fP into either missing tags or
improperly generating inappropriate tags. Although \fBctags\fP has been
designed to handle certain common cases, this is the single biggest cause of
reported problems. In particular, the use of preprocessor constructs which
alter the textual syntax of C can fool \fBctags\fP. You can work around many
such problems by using the \fB-I\fP option.

.PP
When parsing a C++ member function definition (e.g. "className::function"),
\fBctags\fP cannot determine whether the scope specifier is a class name or a
namespace specifier and always lists it as a class name in the scope portion
of the extension flags.

.PP
White space is treated as a separator for file names and options read from
list files, specified using the \fB-L\fP option, and in filter mode (specified
using the \fB--filter\fP option). Therefore, it is not currently possible to
supply file names or other options containing embedded white space (spaces,
etc.) through these options.

.PP
Legacy C source code which uses C++ reserved keywords as variable or parameter
names (e.g. "class", etc.) in a header file may fail to have correct tags
generated for the objects using them. In order to properly handle such code,
use the \fB--lang\fP option.

.PP
Note that when \fBctags\fP generates uses patterns for locating tags (see
the \fB--excmd\fP option), it is entirely possible that the wrong line may be
found by your editor if there exists another source line which is identical to
the line containing the tag. The following example demonstrates this condition:

.PP
.RS
int variable;

/* ... */
.br
void foo(variable)
.br
int variable;
.br
{
.RS 4
/* ... */
.RE
}
.RE

.PP
Depending upon which editor you use and where in the code you happen to be, it
is possible that the search pattern may locate the local parameter declaration
in foo() before it finds the actual global variable definition, since the
lines (and therefore their search patterns are identical). This can be avoided
by use of the \fB--excmd\fP=\fIn\fP option.


.SH "FILES"
.PD 0
.TP 10
.I /etc/ctags.conf
.TP 10
.I /usr/local/etc/ctags.conf
.TP 10
.I $HOME/.ctags
.TP 10
.I .ctags
.br
.PD 1
If any of these configuration files exist, each will be expected to contain a
set of default options which are read in the order listed when \fBctags\fP
starts, but before the \fBCTAGS\fP enviroment variable is read or any command
line options are read. This makes it possible to set up site-wide, personal
or project-level defaults. It is possible to compile \fBctags\fP to read an
additional configuration file immediately before $HOME/.ctags, which will be
indicated if the output produced by the \fB--version\fP option lists the
"custom-conf" feature. Options appearing in the \fBCTAGS\fP enviroment
variable or on the command line will override options specified in these
files. Only options will be read from these files.

.TP 10
.I tags
The default tag file created by \fBctags\fP.
.TP 10
.I TAGS
The default tag file created by \fBetags\fP.

.SH "SEE ALSO"
The official Exuberant Ctags web site at:

.PP
.RS 4
http://darren.hiebert.com/ctags/index.html
.RE

.PP
Also \fBex\fP(1), \fBvi\fP(1), \fBelvis\fP, or, better yet, \fBvim\fP, the
official editor of \fBctags\fP. For more information on \fBvim\fP, see the VIM
Pages web site at:

.PP
.RS 4
http://www.vim.org/
.RE


.SH "AUTHOR"
Darren Hiebert <darren@hiebert.com>, <darren@hiwaay.net>
.br
http://darren.hiebert.com/


.SH "MOTIVATION"
"Think ye at all times of rendering some service to every member of the human
race."

.PP
"All effort and exertion put forth by man from the fullness of his heart is
worship, if it is prompted by the highest motives and the will to do service
to humanity."

.PP
.RS 10
\-- From the Baha'i Writings


.SH "CREDITS"
This version of \fBctags\fP was originally derived from and inspired by the
ctags program by Steve Kirkendall <kirkenda@cs.pdx.edu> that comes with the
Elvis vi clone (though virtually none of the original code remains).

.PP
Credit is also due Bram Moolenaar <Bram@vim.org>, the author of \fBvim\fP, who
has devoted so much of his time and energy both to developing the editor as a
service to others, and to helping the orphans of Uganda.

.PP
The section entitled "HOW TO USE WITH GNU EMACS" was shamelessly stolen from
the man page for GNU \fBetags\fP.
